package com.ywyt.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConnUtil {
    public static Connection getConnection() throws IOException, TimeoutException {
        //1.创建连接对象工厂
        ConnectionFactory factory = new ConnectionFactory();
        //2.设置基本信息
        factory.setHost("192.168.1.109");
        factory.setPort(5672);
        factory.setUsername("admin");
        factory.setPassword("admin");
        factory.setVirtualHost("/");
        //3.获取连接对象
        Connection connection = factory.newConnection();
        //4.返回
        return connection;
    }
}
